<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.js"></script>
<script>
    // Promise all,2个异步请求必须全部完成才会执行then。
    // 如一下案例：就必须要等待10S才可以执行then

    // Promise.all([
    //     new Promise((resolve, reject) => {
    //         setTimeout(() => {
    //             resolve('111')
    //         })
    //     },2000),
    //     new Promise((resolve, reject) => {
    //         setTimeout(() => {
    //             resolve('2222')
    //         },10000)
    //     })
    // ]).then(datas => {
    //     console.log(datas)
    // })

    Promise.all([
        new Promise((resolve, reject) => {
            $.ajax({
                url:"http://localhost:8080/getUser",
                success(data){
                    resolve(data)
                }
            })
        }),
        new Promise((resolve, reject) => {
            $.ajax({
                url:"http://localhost:8080/getUser",
                success(data){
                    resolve(data)
                }
            })
        }),
    ]).then(datas=>{
        for (const data of datas) {
            console.log(data);
        }
    })

</script>
</html>
